package com.sh.data.engine.domain.integration.api.taskconfig.service;

import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.base.model.datax.DataX;
import com.sh.data.engine.domain.integration.api.taskconfig.model.domain.ApiLogDomain;
import com.sh.data.engine.domain.integration.api.taskconfig.model.domain.JarUploadResultDomain;
import com.sh.data.engine.domain.integration.api.taskconfig.model.domain.TaskRecordDomain;
import com.sh.data.engine.domain.integration.api.taskconfig.model.param.PreviewExpressParam;
import com.sh.data.engine.domain.integration.api.taskconfig.model.param.TaskConfigParam;
import com.sh.data.engine.domain.integration.api.taskconfig.model.param.TaskRecordParam;
import com.sh.data.engine.domain.integration.datasource.model.domain.DataSourceDomain;
import com.sh.data.engine.domain.shims.db.model.FieldInfoDomain;
import com.sh.data.engine.domain.shims.db.model.TableInfoDomain;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * Api采集 逻辑接口 apiHttp, apiWs 预览,选表,建表,配字段,配置任务执行周期等步骤均委托给TaskConfigServiceImpl实现类,
 * 若有特殊实现要求,在各自的Impl类中重写
 *
 * @author : changkong
 * @date : 2022/3/10
 */
public interface TaskConfigService {

    public JarUploadResultDomain uploadJar(MultipartFile multipartFile);

    // 预览
    public List<List<Object>> preview(PreviewExpressParam param);

    // 获取数据目标
    public List<DataSourceDomain> getDatabases(Long projectId);

    List<TableInfoDomain> getTargetTables(Long dsId);

    // 获取一键建表语句
    public String getCreateTableDDL(
        Long projectId, Long dsId, List<String> fieldName, Integer isSupportRtf);

    // 一键建表
    public String saveTargetTable(Long project, String sql);

    // 一键建表, 添加数据密级
    public String saveTargetTable(Long project, String sql, Long dataSecretId);

    // 获取关联映射字段
    public List<FieldInfoDomain> getTargetTableFields(Long projectId, String tableName);

    String buildJobJson(DataX.JobContentReader reader, TaskConfigParam task);

    // 操作任务
    void operate(Long taskId, String type);

    PageResult<TaskRecordDomain> historyTask(TaskRecordParam taskRecordParam);

    ApiLogDomain getOfflineSyncLog(Long logId, Integer offset);

    void stop(Long logId);

    Boolean ignoreApiRunningRecord(String ids);
}
